package com.obas.integration.aaa.service.impl;

import java.util.Date;

import com.ease.common.util.DateFormatUtil;
import com.ease.common.util.DateUtil;
import com.obas.integration.aaa.service.AaaIntegrationFileService;
import com.obas.integration.common.service.impl.AbstractIntegrationFileServiceImpl;

public class AaaIntegrationFileServiceImpl extends AbstractIntegrationFileServiceImpl implements AaaIntegrationFileService {

	public void doLoad(String fileNamePrefix, Date batchTimestamp, final String controlTemplateName) {

		String fileName = fileNamePrefix + DateFormatUtil.toDatatimeNumberString(batchTimestamp) + ".txt";

		this.load(fileName, batchTimestamp, controlTemplateName);
	}

	public void loadAaaCustomer() {

		String fileNamePrefix = "user_info_";
		String controlTemplateName = "aaa.customer.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastQuarterDate(date);

		this.doLoad(fileNamePrefix, batchTimestamp, controlTemplateName);
	}

	public void loadAaaOnline() {

		String fileNamePrefix = "online_";
		String controlTemplateName = "aaa.online.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastQuarterDate(date);

		this.load(fileNamePrefix, batchTimestamp, controlTemplateName);

	}

	public void loadAaaSession() {

		String fileNamePrefix = "det_";
		String controlTemplateName = "aaa.session.ctl.ftl";

		Date date = new Date();
		Date batchTimestamp = DateUtil.getLastHalfHourDate(date);

		this.load(fileNamePrefix, batchTimestamp, controlTemplateName);

	}

}
